﻿<?php
// ------------------------------------------------------------------
// NEEDED STUBS FOR THIS EXAMPLE
// ------------------------------------------------------------------


// this will include all needed files to be able to build a Request
include_once($CONF["STUBS_FOLDER"]."Map24MapletRemoteControl/Map24MapletRemoteControl.php5");


// ------------------------------------------------------------------
// NEEDED PARAMETERS FOR THIS REQUEST
// ------------------------------------------------------------------


// coordinates of the locations to add
$longitude1	= "514.048";
$latitude1 	= "3007.8325";

$longitude2	= "515.048";
$latitude2 	= "3007.8325";

$longitude3	= "516.048";
$latitude3 	= "3007.8325";

// symbol used 	to display the location
$symbolId1	= "201";
$symbolId2	= "202";
$symbolId3	= "203";


// zoomlevel
$mapViewClippingWidth = 2000;


// ------------------------------------------------------------------
// BUILDING THE REQUEST
// ------------------------------------------------------------------


// here are all commands defined and are put together in one ArrayOfCommands

// this object will add a new location
$cmdIdx=0;
$commands[$cmdIdx] = new XMLCommandWrapper();
$commands[$cmdIdx]->DeclareMap24Location = new DeclareMap24Location();
$commands[$cmdIdx]->DeclareMap24Location->MapObjectID = "location1";
$commands[$cmdIdx]->DeclareMap24Location->Coordinate = new Coordinate();
$commands[$cmdIdx]->DeclareMap24Location->Coordinate->Longitude = $longitude1;
$commands[$cmdIdx]->DeclareMap24Location->Coordinate->Latitude = $latitude1;
$commands[$cmdIdx]->DeclareMap24Location->SymbolID = $symbolId1;

// this object will add a second location
$cmdIdx++;
$commands[$cmdIdx] = new XMLCommandWrapper();
$commands[$cmdIdx]->DeclareMap24Location = new DeclareMap24Location();
$commands[$cmdIdx]->DeclareMap24Location->MapObjectID = "location2";
$commands[$cmdIdx]->DeclareMap24Location->Coordinate = new Coordinate();
$commands[$cmdIdx]->DeclareMap24Location->Coordinate->Longitude = $longitude2;
$commands[$cmdIdx]->DeclareMap24Location->Coordinate->Latitude = $latitude2;
$commands[$cmdIdx]->DeclareMap24Location->SymbolID = $symbolId2;

// this object will add a third location
$cmdIdx++;
$commands[$cmdIdx] = new XMLCommandWrapper();
$commands[$cmdIdx]->DeclareMap24Location = new DeclareMap24Location();
$commands[$cmdIdx]->DeclareMap24Location->MapObjectID = "location3";
$commands[$cmdIdx]->DeclareMap24Location->Coordinate = new Coordinate();
$commands[$cmdIdx]->DeclareMap24Location->Coordinate->Longitude = $longitude3;
$commands[$cmdIdx]->DeclareMap24Location->Coordinate->Latitude = $latitude3;
$commands[$cmdIdx]->DeclareMap24Location->SymbolID = $symbolId3;

// this will add the objects to a Grupp
$cmdIdx++;
$commands[$cmdIdx] = new XMLCommandWrapper();
$commands[$cmdIdx]->DeclareMapObjectGroup = new DeclareMapObjectGroup();
$commands[$cmdIdx]->DeclareMapObjectGroup->MapObjectGroupID = "all";
$commands[$cmdIdx]->DeclareMapObjectGroup->MapObjectIDs = array("location1","location2","location3");

// this object will enable the new location on the map
$cmdIdx++;
$commands[$cmdIdx] = new XMLCommandWrapper();
$commands[$cmdIdx]->ControlMapObject = new ControlMapObject();
$commands[$cmdIdx]->ControlMapObject->Control = "SHOW";
$commands[$cmdIdx]->ControlMapObject->MapObjectIDs = array("all");

// this object will center the map above the new location
$cmdIdx++;
$commands[$cmdIdx] = new XMLCommandWrapper();
$commands[$cmdIdx]->SetMapView = new SetMapView();
$commands[$cmdIdx]->SetMapView->MapObjectIDs = array("all");
$commands[$cmdIdx]->SetMapView->ClippingWidth = new SetMapViewClippingWidth();
$commands[$cmdIdx]->SetMapView->ClippingWidth->MinimumWidth = $mapViewClippingWidth;

// definition of the request header with Map24ID and SessionID
$header = new RequestHeader();
$header->Map24ID  = $CONF['MAP24_ID'];
$header->ClientID = $CONF['SESSION_ID'];

// definition of the request body
$request = new MapletRemoteControlRequest();
$request->Map24MRC = new Map24MRC();
$request->Map24MRC->Commands = $commands;


// ------------------------------------------------------------------
// EXECUTE THE REQUEST
// ------------------------------------------------------------------


// in this object the SoapClient will be initiated and executed
$mrc = new Map24MapletRemoteControl($CONF['MAPTP_SYSTEM'],$CONF['MAP24_ID'],$CONF['SESSION_ID']);
$response = $mrc->mapletRemoteControl($header,$request);


// ------------------------------------------------------------------
// OUTPUT THE RESULT
// ------------------------------------------------------------------


$resultString = "This command generates no output";
$counter = 0;
?>